add_executable(main main.cpp)

add_library(mylib mylib.h mylib.cpp)

if(WIN32)
    set(WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif()

add_library(mylib-shared SHARED mylib.h mylib.cpp)

target_include_directories(mylib 
    PUBLIC 
    ${CMAKE_CURRENT_LIST_DIR}
)

target_include_directories(mylib-shared 
    PUBLIC 
    ${CMAKE_CURRENT_LIST_DIR}
)

target_link_libraries(main mylib-shared)

#DESTINATION 表示是以相对路径的形式指定目标文件安装的位置，而不是绝对路径。
install(TARGETS main mylib mylib-shared
    ARCHIVE DESTINATION lib
    RUNTIME DESTINATION bin
    LIBRARY DESTINATION lib
)

install(FILES mylib.h 
    DESTINATION include
)

install(FILES ${CMAKE_CURRENT_LIST_DIR}/README.md 
    DESTINATION doc
)